//
//  ThreeViewController.m
//  WYModel
//
//  Created by ios on 2017/3/2.
//  Copyright © 2017年 Wy. All rights reserved.
//

#import "ThreeViewController.h"
#import "WYPlaceholderView.h"

@interface ThreeViewController ()

@property(nonatomic,strong)WYPlaceholderView *placeholderView;
@end

@implementation ThreeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
     //w_nonet 网络错误图
    [self.placeholderView wyPlaceholderImage:[UIImage imageNamed:@"no_order"] withTitle:@"未添加商品到购物车" buttonTitle:@"去逛逛～"];
    WS(weakSelf);
    self.placeholderView.block = ^(){
         WYLog(@"没有商品");
        [weakSelf.placeholderView removeFromSuperview];
        weakSelf.placeholderView = nil;
        //重新请求数据或加载
    };
    
    
    [self.view addSubview:self.placeholderView];

    [self performSelector:@selector(change) withObject:self afterDelay:10];
}

-(void)change{
    
    [self.placeholderView wyPlaceholderImage:[UIImage imageNamed:@"w_nonet"] withTitle:@"网络飞走啦～～" buttonTitle:@"重新加载"];
    [self.view addSubview:self.placeholderView];
    WS(weakSelf);
    self.placeholderView.block = ^(){
        WYLog(@"网络异常");
        [weakSelf.placeholderView removeFromSuperview];
         weakSelf.placeholderView = nil;
        //重新请求数据或加载
    };
    
}




-(WYPlaceholderView *)placeholderView{
    
    if (_placeholderView ==nil) {
        _placeholderView = [[WYPlaceholderView alloc] initWithFrame:CGRectMake(0, 0, kWidth, kHeight)];
        
    }
    return _placeholderView;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
